<?php

class VideoPeer extends BaseVideoPeer
{
	public static function getLatestVideo() {
		$obj = DbFinder::from('Video')
						->with('I18n')
						->where('IsPublic',1)
						->orderBy('CreatedAt', 'desc')
						->find(1);
		return $obj[0];
	}
	
	public static function getListRelated($video_id,$limit=5) {
		$obj = DbFinder::from('Video')
						->with('I18n')
						->where('Video.Id','<',$video_id)
						->where('IsPublic',1)
						->orderBy('CreatedAt', 'desc')
						->find($limit);
		return $obj;
	}
	
	public static function getListWithPagination($start = 1,$limit = 10) {
		return DbFinder::from('Video')
						->with('I18n')
						->where('IsPublic',1)
						->orderBy('CreatedAt', 'desc')
						//->useCache(sfConfig::get('sf_cache'), 200)
						->paginate($start, $limit);
	}
}
